
#ifndef WORLD_H_
#define WORLD_H_

#include "LibraryFrameworkExport.h"
#include "AI\Graph\SparseGraph.h"
#include "SpacePartitioning\CellSpacePartition.h"
#include "AI\Graph\GraphNodeTypes.h"
#include "AI\Graph\GraphEdgeTypes.h"
#include "Entities\BaseEntity.h"

#include <vector>
#include "Maths\2D\Line2D.h"
#include "Maths\Vector2.h"

namespace CasaEngine
{
	//typedef NavGraphNode<Trigger<Raven_Bot>*>         GraphNode;	
	typedef SparseGraph<GraphNode, NavGraphEdge> NavGraph;
	typedef CellSpacePartition<NavGraph::NodeType*> CellSpace;

	/*
	 *	
	 */
	class LIBRARY_FRAMEWORK_EXPORT World
	{
	public:
		World();
		virtual ~World();

		const std::vector<BaseEntity *>& GetEntities();

		CellSpace* GetSpacePartition() const;
		void SetSpacePartition(CellSpace* val);

		//==== boid & simple soccer =================

		const std::vector<Line2D>& Walls(){return m_Walls;}  
		const std::vector<BaseEntity*>& Obstacles()const{return m_Obstacles;}
		
		CellSpacePartition<BaseEntity*>* GetCellSpcEntity() const;
		void SetCellSpcEntity(CellSpacePartition<BaseEntity*>* val);

		Vector2F    Crosshair()const{return m_vCrosshair;}
		void        SetCrosshair(Vector2F v){m_vCrosshair=v;}
		void Update( const GameTime& gameTime_ );
		void AddEntity( BaseEntity* pEntity );
		//============================================

	private:

		//==== boid & simple soccer =================
		
		//the position of the crosshair
		Vector2F                      m_vCrosshair;
		//container containing any walls in the environment
		std::vector<Line2D>           m_Walls;
		//any obstacles
		std::vector<BaseEntity*>  m_Obstacles;

		//cellspace : boids & simple soccer
		CellSpacePartition<BaseEntity*>* m_pCellSpace;

		//============================================

		std::vector<BaseEntity *> m_Entities;
		//any obstacles
		//std::vector<BaseEntity*>  m_Obstacles;

		//this map's accompanying navigation graph
		NavGraph* m_pNavGraph;  

		//the graph nodes will be partitioned enabling fast lookup
		CellSpace* m_pSpacePartition;
		
	};

} // namespace CasaEngine

#endif // GAMEINFO_H_
